package com.wondertek.poms.dao.repo.es.impl;

import com.wondertek.poms.common.utils.StringUtil;
import com.wondertek.poms.dao.po.PrdCont;
import com.wondertek.poms.dao.po.PrdInfo;
import com.wondertek.poms.dao.po.es.ContentVo;
import com.wondertek.poms.dao.repo.IPrdContDao;
import com.wondertek.poms.dao.repo.IPrdInfoDao;
import com.wondertek.poms.dao.repo.ISystemConfigDao;
import com.wondertek.poms.dao.repo.es.IPrdContESDao;
import com.wondertek.poms.dao.util.ESUtils;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author chenjijiang
 * @description
 */
@Slf4j
@Component
public class PrdContESDaoImpl implements IPrdContESDao {

	@Autowired
	private ISystemConfigDao systemConfigDao;
	@Autowired
	private IPrdInfoDao prdInfoDao;
	@Autowired
	private IPrdContDao prdContDao;

	@Override
	public long getContentCountByMap(Map<String, Object> paramMap, Long id) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		TransportClient client = ESUtils.getTransportClient();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);
		BoolQueryBuilder qb = QueryBuilders.boolQuery();

		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("selectType"))) {
			if ("1".equals(StringUtil.null2Str(paramMap.get("selectType")))) {
				if (!StringUtil.isNullStr(paramMap.get("selectProInfoId"))) {
					qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("selectProInfoId"))));
				} else {
					String packageId = (String) paramMap.get("packageId");
					List<PrdInfo> prdList = prdInfoDao.findAllByProductInfoPackageId(Long.valueOf(packageId));
					if (prdList != null && prdList.size() > 0) {
						BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
						for (PrdInfo prd : prdList) {
							prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", prd.getPrdInfoId()));
						}
						qb.filter(prdInfoBQB);
					} else {
						log.info("====packageId:" + packageId + "===没找到对应的产品包ID");
						return 0;
					}
				}
			} else {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", id));
			}
		} else {
			qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", id));
		}

		if (!StringUtil.isNullStr(paramMap.get("accessPlatFormType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.ACCESSPLATFORMTYPE", StringUtil.nullToString(paramMap.get("accessPlatFormType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cpId"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_CPID", StringUtil.nullToString(paramMap.get("cpId"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("charge"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FEE_TYPE", StringUtil.nullToString(paramMap.get("charge"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("keywords"))) {
			qb.must(QueryBuilders.multiMatchQuery(paramMap.get("keywords"),
					"CONTENT.KEY_WORDS", "CONTENT.PRIMARY_KEY_WORD", "CONTENT.DETAIL", "CONTENT.LABELS", "CONTENT.NAME"));
		}
		if (!StringUtil.isNullStr(paramMap.get("bcType"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));

			if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
			}
		} else {
			if (!StringUtil.isNullStr(paramMap.get("viewType")) && paramMap.get("viewType").toString().equals("4")) {//已播控列表
				if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
					qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
				} else {
					qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("BC_STATUS", 1)).should(QueryBuilders.termQuery("BC_STATUS", 2)));
				}
			} else if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
			}
		}

		if (StringUtil.isNullStr(paramMap.get("contentId")) && StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			if (!StringUtil.isNullStr(paramMap.get("startTime")) && !StringUtil.isNullStr(paramMap.get("endTime"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(((String) paramMap.get("startTime")).substring(0, 10)).includeLower(true)
						.to(((String) paramMap.get("endTime")).substring(0, 10)).includeUpper(true));
			} else {
				Calendar cal = Calendar.getInstance();
				cal.add(Calendar.DAY_OF_MONTH, -2);
				Date startDate = cal.getTime();
				cal.add(Calendar.DAY_OF_MONTH, +3);
				Date endDate = cal.getTime();
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format(startDate)).includeLower(true)
						.to(sdf.format(endDate)).includeUpper(true));
			}
			if (!StringUtil.isNullStr(paramMap.get("createTimeBegin")) && !StringUtil.isNullStr(paramMap.get("createTimeEnd"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.CREATE_TIME")
						.from(((String) paramMap.get("createTimeBegin")).substring(0, 10)).includeLower(true)
						.to(((String) paramMap.get("createTimeEnd")).substring(0, 10)).includeUpper(true));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("disStatus"))) {
			qb.filter(QueryBuilders.termQuery("DIST_STATUS", StringUtil.nullToString(paramMap.get("disStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("pubStatus"))) {
			qb.filter(QueryBuilders.termQuery("PUB_STATUS", StringUtil.nullToString(paramMap.get("pubStatus"))));
		}
		//内容类型：爱情|喜剧；内容形态：预告
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			String sc = StringUtil.null2Str(paramMap.get("secondClassify")).replaceAll("：", ":").replaceAll("；", ";");
			if (sc.indexOf(":") > -1) {
				String[] sca = sc.split(";");
				if (sca != null && sca.length > 0) {
					for (String scc : sca) {
						String[] scca = scc.split(":");
						if (scca != null && scca.length == 2) {
							String key = scca[0];
							String value = scca[1];

							if (value.indexOf("|") > -1) {
								String[] vala = value.split("\\|");
								if (vala != null && vala.length > 0) {

									BoolQueryBuilder temp_bqb = QueryBuilders.boolQuery();
									for (int ii = 0; ii < vala.length; ii++) {
										temp_bqb.should(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(vala[ii]) + "*"));
									}

									qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
											QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key)).must(temp_bqb)));
								}
							} else {
								qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
										QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key))
												.must(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(value) + "*"))));
							}
						}
					}
				}
			}
		}
		//节目ID
		if (!StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			qb.filter(QueryBuilders.termQuery("PRD_CONT_ID", StringUtil.nullToLong(paramMap.get("firstLabel").toString().trim())));
		}

		//mpid,mcid,mvid,migudbid
		if (!StringUtil.isNullStr(paramMap.get("mpid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MP_ID", StringUtil.nullToLong(paramMap.get("mpid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("MiguDBID"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MIGU_DBID", StringUtil.nullToLong(paramMap.get("MiguDBID").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("mvid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MV_ID", StringUtil.nullToLong(paramMap.get("mvid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("mcid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MC_ID", StringUtil.nullToLong(paramMap.get("mcid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("author"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.AUTHOR", StringUtil.nullToString(paramMap.get("author").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("equityId"))) {
			//QueryBuilder queryBuilder=QueryBuilders.matchQuery("EQUITY_ID", StringUtil.nullToString(paramMap.get("equityId")));
			QueryBuilder queryBuilder = QueryBuilders.wildcardQuery("EQUITY_ID", "*" + StringUtil.nullToString(paramMap.get("equityId")) + "*");
			qb.must(queryBuilder);
		}

		//新发布状态
		if (!StringUtil.isNullStr(paramMap.get("vomsPublish"))) {
			if (paramMap.get("vomsPublish").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", StringUtil.nullToLong(paramMap.get("vomsPublish").toString().trim())));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("shieldDelCont")) && paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));
		}

		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			QueryStringQueryBuilder queryBuilder = new QueryStringQueryBuilder(StringUtil.nullToString(paramMap.get("contentName")));
			queryBuilder.field("CONTENT.NAME");
			queryBuilder.analyzer("ik_smart");
			qb.must(queryBuilder);
		}
		if (!StringUtil.isNullStr(paramMap.get("assist"))) {
			QueryBuilder queryBuilder = QueryBuilders.matchQuery("CONTENT.ASSIST", StringUtil.nullToString(paramMap.get("assist")));
			qb.must(queryBuilder);
		}
		if (!StringUtil.isNullStr(paramMap.get("contentId"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId"))))
					.should(QueryBuilders.termQuery("CONTENT.SERIAL_CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId")))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", StringUtil.nullToString(paramMap.get("recommendation")).toLowerCase()));
		}
		if (!StringUtil.isNullStr(paramMap.get("serialSequence"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.SERIAL_SEQUENCE", StringUtil.nullToString(paramMap.get("serialSequence"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("status"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("status"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("copyRightType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_TYPE", StringUtil.nullToString(paramMap.get("copyRightType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("scopeOfAuthor"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.SCOPE", StringUtil.nullToString(paramMap.get("scopeOfAuthor"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cdnStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CDN_STATUS", StringUtil.nullToString(paramMap.get("cdnStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("gslbStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", StringUtil.nullToString(paramMap.get("gslbStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cacheCdnStatus"))) {
			if (paramMap.get("cacheCdnStatus").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", StringUtil.nullToString(paramMap.get("cacheCdnStatus"))));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("formType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FORM_TYPE", StringUtil.nullToString(paramMap.get("formType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("albumStatus"))) {
			qb.mustNot(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("albumStatus"))));
		}
		if (StringUtil.isNullStr(paramMap.get("bcType"))) {
			if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {
				qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("optimal"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("optimal")))) {
				qb.filter(QueryBuilders.termQuery("CONTENT.OPTIMAL", StringUtil.nullToString(paramMap.get("optimal"))));
			} else {
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.termQuery("OPTIMAL", "1"))
						.should(QueryBuilders.termQuery("OPTIMAL", "null")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("prdContXT"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容形态"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("prdContXT"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("releaseTime"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "播出年代"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("releaseTime"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("area"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "国家及地区"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("area")) + "*"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contCatergry"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容类型"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("contCatergry")) + "*"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("orderFlag"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//包月
				qb.mustNot(QueryBuilders.termQuery("PRD_INFO.MONTH_TYPE", "null"))
						.filter(QueryBuilders.termQuery("PRODUCT_ID", "null"));
			} else if ("1".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//按次
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.NUMBER_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "1")));
			} else if ("7".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//免费
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.FREE_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "7")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("channelPackageId"))) {

			if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.filter(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.should(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			}
		}

		builder.setQuery(qb);
		System.out.println("=====paramMap:===" + paramMap);
		System.out.println("===== Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();
		System.out.println("===== hits.getTotalHits():===" + hits.getTotalHits());
		return hits.getTotalHits();
	}

	@Override
	public long getProvinceContentCountByMap(Map<String, Object> paramMap, Long id) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		TransportClient client = ESUtils.getTransportClient();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);
		BoolQueryBuilder qb = QueryBuilders.boolQuery();

		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("PRD_INFO_ID"))) {
			if (((String) paramMap.get("PRD_INFO_ID")).indexOf(",") <= 0) {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("PRD_INFO_ID"))));
			} else {
				String[] pids = ((String) paramMap.get("packageId")).split(",");
				BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
				for (int i = 0; i < pids.length; i++) {
					prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", pids[i]));
				}
				qb.filter(prdInfoBQB);
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("cpId"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_CPID", StringUtil.nullToString(paramMap.get("cpId"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("charge"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FEE_TYPE", StringUtil.nullToString(paramMap.get("charge"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("keywords"))) {
			qb.must(QueryBuilders.multiMatchQuery(paramMap.get("keywords"),
					"CONTENT.KEY_WORDS", "CONTENT.PRIMARY_KEY_WORD", "CONTENT.DETAIL", "CONTENT.LABELS", "CONTENT.NAME"));
		}
		if (!StringUtil.isNullStr(paramMap.get("bcType"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));

			if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
			}
		} else {
			if (!StringUtil.isNullStr(paramMap.get("viewType")) && paramMap.get("viewType").toString().equals("4")) {//已播控列表
				if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
					qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
				} else {
					qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("BC_STATUS", 1)).should(QueryBuilders.termQuery("BC_STATUS", 2)));
				}
			} else if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToString(paramMap.get("bcStatus"))));
			}
		}
		if (StringUtil.isNullStr(paramMap.get("contentId")) && StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			if (!StringUtil.isNullStr(paramMap.get("startTime")) && !StringUtil.isNullStr(paramMap.get("endTime"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format((String) paramMap.get("startTime"))).includeLower(true)
						.to(sdf.format((String) paramMap.get("endTime"))).includeUpper(true));
			} else {
				Calendar cal = Calendar.getInstance();
				cal.add(Calendar.DAY_OF_MONTH, -2);
				Date startDate = cal.getTime();
				cal.add(Calendar.DAY_OF_MONTH, +3);
				Date endDate = cal.getTime();
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format(startDate)).includeLower(true)
						.to(sdf.format(endDate)).includeUpper(true));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("disStatus"))) {
			qb.filter(QueryBuilders.termQuery("DIST_STATUS", StringUtil.nullToString(paramMap.get("disStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("pubStatus"))) {
			qb.filter(QueryBuilders.termQuery("PUB_STATUS", StringUtil.nullToString(paramMap.get("pubStatus"))));
		}
		//内容类型：爱情|喜剧；内容形态：预告
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			String sc = StringUtil.null2Str(paramMap.get("secondClassify")).replaceAll("：", ":").replaceAll("；", ";");
			if (sc.indexOf(":") > -1) {
				String[] sca = sc.split(";");
				if (sca != null && sca.length > 0) {
					for (String scc : sca) {
						String[] scca = scc.split(":");
						if (scca != null && scca.length == 2) {
							String key = scca[0];
							String value = scca[1];

							if (value.indexOf("|") > -1) {
								String[] vala = value.split("\\|");
								if (vala != null && vala.length > 0) {

									BoolQueryBuilder temp_bqb = QueryBuilders.boolQuery();
									for (int ii = 0; ii < vala.length; ii++) {
										temp_bqb.should(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(vala[ii]) + "*"));
									}

									qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
											QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key)).must(temp_bqb)));
								}
							} else {
								qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
										QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key))
												.must(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(value) + "*"))));
							}
						}
					}
				}
			}
		}
		//节目ID
		if (!StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			qb.filter(QueryBuilders.termQuery("PRD_CONT_ID", StringUtil.nullToLong(paramMap.get("firstLabel").toString().trim())));
		}
		//新发布状态
		if (!StringUtil.isNullStr(paramMap.get("vomsPublish"))) {
			if (paramMap.get("vomsPublish").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", StringUtil.nullToLong(paramMap.get("vomsPublish").toString().trim())));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("shieldDelCont")) && paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));
		}

		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			qb.filter(QueryBuilders.queryStringQuery(StringUtil.nullToString(paramMap.get("contentName"))).analyzer("ik_smart").field("CONTENT.NAME"));
			//qb.must(QueryBuilders.termQuery("CONTENT.NAME", StringUtil.nullToString(paramMap.get("contentName"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentId"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId"))))
					.should(QueryBuilders.termQuery("CONTENT.SERIAL_CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId")))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", StringUtil.nullToString(paramMap.get("recommendation"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("status"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("status"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("copyRightType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_TYPE", StringUtil.nullToString(paramMap.get("copyRightType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("scopeOfAuthor"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.SCOPE", StringUtil.nullToString(paramMap.get("scopeOfAuthor"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cdnStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CDN_STATUS", StringUtil.nullToString(paramMap.get("cdnStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("gslbStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", StringUtil.nullToString(paramMap.get("gslbStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cacheCdnStatus"))) {
			if (paramMap.get("cacheCdnStatus").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", StringUtil.nullToString(paramMap.get("cacheCdnStatus"))));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("formType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FORM_TYPE", StringUtil.nullToString(paramMap.get("formType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("albumStatus"))) {
			qb.mustNot(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("albumStatus"))));
		}
		if (StringUtil.isNullStr(paramMap.get("bcType"))) {
			if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {
				qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("optimal"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("optimal")))) {
				qb.filter(QueryBuilders.termQuery("CONTENT.OPTIMAL", StringUtil.nullToString(paramMap.get("optimal"))));
			} else {
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.termQuery("OPTIMAL", "1"))
						.should(QueryBuilders.termQuery("OPTIMAL", "null")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("prdContXT"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容形态"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("prdContXT"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("releaseTime"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "播出年代"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("releaseTime"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("area"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "国家及地区"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("area")) + "*"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contCatergry"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容类型"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("contCatergry")) + "*"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("orderFlag"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//包月
				qb.mustNot(QueryBuilders.termQuery("PRD_INFO.MONTH_TYPE", "null"))
						.filter(QueryBuilders.termQuery("PRODUCT_ID", "null"));
			} else if ("1".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//按次
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.NUMBER_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "1")));
			} else if ("7".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//免费
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.FREE_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "7")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("channelPackageId"))) {

			if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.filter(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.should(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			}
		}

		builder.setQuery(qb);
		System.out.println("=====paramMap:===" + paramMap);
		System.out.println("===== Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();
		System.out.println("===== hits.getTotalHits():===" + hits.getTotalHits());
		return hits.getTotalHits();
	}

	@Override
	public List<ContentVo> getContentList(Map<String, Object> paramMap, int start, int limit, Long id) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		TransportClient client = ESUtils.getTransportClient();
		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);

		BoolQueryBuilder qb = QueryBuilders.boolQuery();
		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("selectType"))) {
			if ("1".equals(StringUtil.null2Str(paramMap.get("selectType")))) {
				if (!StringUtil.isNullStr(paramMap.get("selectProInfoId"))) {
					qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("selectProInfoId"))));
				} else {
					String packageId = (String) paramMap.get("packageId");
					List<PrdInfo> prdList = prdInfoDao.findAllByProductInfoPackageId(Long.valueOf(packageId));
					if (prdList != null && prdList.size() > 0) {
						BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
						for (PrdInfo prd : prdList) {
							prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", prd.getPrdInfoId()));
						}
						qb.filter(prdInfoBQB);
					} else {
						log.info("====packageId:" + packageId + "===没找到对应的产品包ID");
						return null;
					}
				}
			} else {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", id));
			}
		} else {
			qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", id));
		}

		if (!StringUtil.isNullStr(paramMap.get("cpId"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_CPID", StringUtil.nullToString(paramMap.get("cpId"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("charge"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FEE_TYPE", StringUtil.nullToString(paramMap.get("charge"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("keywords"))) {
			qb.must(QueryBuilders.multiMatchQuery(StringUtil.nullToString(paramMap.get("keywords"))
					, "CONTENT.KEY_WORDS", "CONTENT.PRIMARY_KEY_WORD", "CONTENT.DETAIL", "CONTENT.LABELS", "CONTENT.NAME"));
		}
		if (!StringUtil.isNullStr(paramMap.get("bcType"))) {//待播控
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));

			if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
			}
		} else {

			if (!StringUtil.isNullStr(paramMap.get("viewType")) && paramMap.get("viewType").toString().equals("4")) {
				if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
					qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
				} else {
					qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("BC_STATUS", 1)).should(QueryBuilders.termQuery("BC_STATUS", 2)));
				}
			} else if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
			}
		}

		if (StringUtil.isNullStr(paramMap.get("contentId")) && StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			if (!StringUtil.isNullStr(paramMap.get("startTime")) && !StringUtil.isNullStr(paramMap.get("endTime"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(((String) paramMap.get("startTime")).substring(0, 10)).includeLower(true)
						.to(((String) paramMap.get("endTime")).substring(0, 10)).includeUpper(true));
			} else {
				Calendar cal = Calendar.getInstance();
				cal.add(Calendar.DAY_OF_MONTH, -2);
				Date startDate = cal.getTime();
				cal.add(Calendar.DAY_OF_MONTH, +3);
				Date endDate = cal.getTime();
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format(startDate)).includeLower(true)
						.to(sdf.format(endDate)).includeUpper(true));
			}

			if (!StringUtil.isNullStr(paramMap.get("createTimeBegin")) && !StringUtil.isNullStr(paramMap.get("createTimeEnd"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.CREATE_TIME")
						.from(((String) paramMap.get("createTimeBegin")).substring(0, 10)).includeLower(true)
						.to(((String) paramMap.get("createTimeEnd")).substring(0, 10)).includeUpper(true));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("disStatus"))) {
			qb.filter(QueryBuilders.termQuery("DIST_STATUS", StringUtil.nullToInteger(paramMap.get("disStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("pubStatus"))) {
			qb.filter(QueryBuilders.termQuery("PUB_STATUS", StringUtil.nullToInteger(paramMap.get("pubStatus"))));
		}

		//内容类型：爱情|喜剧；内容形态：预告
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			String sc = StringUtil.null2Str(paramMap.get("secondClassify")).replaceAll("：", ":").replaceAll("；", ";");
			if (sc.indexOf(":") > -1) {
				String[] sca = sc.split(";");
				if (sca != null && sca.length > 0) {
					for (String scc : sca) {
						String[] scca = scc.split(":");
						if (scca != null && scca.length == 2) {
							String key = scca[0];
							String value = scca[1];

							if (value.indexOf("|") > -1) {
								String[] vala = value.split("\\|");
								if (vala != null && vala.length > 0) {

									BoolQueryBuilder temp_bqb = QueryBuilders.boolQuery();
									for (int ii = 0; ii < vala.length; ii++) {
										temp_bqb.should(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(vala[ii]) + "*"));
									}

									qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
											QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key)).filter(temp_bqb)));
								}
							} else {
								qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
										QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key))
												.must(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(value) + "*"))));
							}
						}
					}
				}
			}
		}

		//节目ID
		if (!StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			qb.filter(QueryBuilders.termQuery("PRD_CONT_ID", StringUtil.nullToLong(paramMap.get("firstLabel").toString().trim())));
		}

		//mpid,mcid,mvid,migudbid
		if (!StringUtil.isNullStr(paramMap.get("mpid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MP_ID", StringUtil.nullToLong(paramMap.get("mpid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("MiguDBID"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MIGU_DBID", StringUtil.nullToLong(paramMap.get("MiguDBID").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("mvid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MV_ID", StringUtil.nullToLong(paramMap.get("mvid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("mcid"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.MC_ID", StringUtil.nullToLong(paramMap.get("mcid").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("author"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.AUTHOR", StringUtil.nullToString(paramMap.get("author").toString().trim())));
		}
		if (!StringUtil.isNullStr(paramMap.get("equityId"))) {
			//QueryBuilder queryBuilder=QueryBuilders.matchQuery("EQUITY_ID", StringUtil.nullToString(paramMap.get("equityId")));
			QueryBuilder queryBuilder = QueryBuilders.wildcardQuery("EQUITY_ID", "*" + StringUtil.nullToString(paramMap.get("equityId")) + "*");
			qb.must(queryBuilder);
		}

		//新发布状态
		if (!StringUtil.isNullStr(paramMap.get("vomsPublish"))) {
			if (paramMap.get("vomsPublish").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", StringUtil.nullToLong(paramMap.get("vomsPublish").toString().trim())));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("shieldDelCont")) && paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			QueryStringQueryBuilder queryBuilder = new QueryStringQueryBuilder(StringUtil.nullToString(paramMap.get("contentName")));
			queryBuilder.field("CONTENT.NAME");
			queryBuilder.analyzer("ik_smart");
			qb.must(queryBuilder);
		}
		if (!StringUtil.isNullStr(paramMap.get("assist"))) {
			/*QueryStringQueryBuilder queryBuilder = new QueryStringQueryBuilder(StringUtil.nullToString(paramMap.get("assist")));
			queryBuilder.field("CONTENT.ASSIST");
			queryBuilder.analyzer("ik_smart");
			qb.must(queryBuilder);*/
			QueryBuilder queryBuilder = QueryBuilders.matchQuery("CONTENT.ASSIST", StringUtil.nullToString(paramMap.get("assist")));
			qb.must(queryBuilder);
		}
		if (!StringUtil.isNullStr(paramMap.get("serialSequence"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.SERIAL_SEQUENCE", StringUtil.nullToString(paramMap.get("serialSequence"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentId"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId"))))
					.should(QueryBuilders.termQuery("CONTENT.SERIAL_CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId")))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", StringUtil.nullToString(paramMap.get("recommendation")).toLowerCase()));
		}
		if (!StringUtil.isNullStr(paramMap.get("status"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("status"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("copyRightType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_TYPE", StringUtil.nullToString(paramMap.get("copyRightType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("scopeOfAuthor"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.SCOPE", StringUtil.nullToString(paramMap.get("scopeOfAuthor"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cdnStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CDN_STATUS", StringUtil.nullToString(paramMap.get("cdnStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("gslbStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", StringUtil.nullToString(paramMap.get("gslbStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cacheCdnStatus"))) {
			if (paramMap.get("cacheCdnStatus").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", StringUtil.nullToString(paramMap.get("cacheCdnStatus"))));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("albumStatus"))) {
			qb.mustNot(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("albumStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("formType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FORM_TYPE", StringUtil.nullToString(paramMap.get("formType"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("optimal"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("optimal")))) {
				qb.filter(QueryBuilders.termQuery("CONTENT.OPTIMAL", StringUtil.nullToString(paramMap.get("optimal"))));
			} else {
				qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("CONTENT.OPTIMAL", "1")).should(QueryBuilders.termQuery("CONTENT.OPTIMAL", "null")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("prdContXT"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容形态"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("prdContXT"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("releaseTime"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "播出年代"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("releaseTime"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("area"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "国家及地区"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("area")) + "*"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contCatergry"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容类型"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("contCatergry")) + "*"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("orderFlag"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//包月
				qb.mustNot(QueryBuilders.termQuery("PRD_INFO.MONTH_TYPE", "null")).filter(QueryBuilders.termQuery("PRODUCT_ID", "null"));
			} else if ("1".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//按次
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.NUMBER_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "1")));
			} else if ("7".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//免费
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.FREE_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "7")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("channelPackageId"))) {

			if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.filter(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.should(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			}
		}

		if (paramMap.get("bcType") != null && !StringUtil.isNullStr(paramMap.get("bcType"))) {
			builder.addSort(SortBuilders.fieldSort("CONTENT.STATUS").order(SortOrder.DESC));
			builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_UPDATE_TIME").order(SortOrder.DESC));
		} else {
			if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {//1-显示子集， 其他-不显示子集
				qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
				if (StringUtil.isNullStr(paramMap.get("contentName")) && StringUtil.isNullStr(paramMap.get("keywords"))) {
					builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_UPDATE_TIME").order(SortOrder.DESC));
				}
			}
		}
		List<ContentVo> contentVoList = new ArrayList<ContentVo>();

		builder.setQuery(qb).setFrom(start).setSize(limit);
		System.out.println("=====GETLIST paramMap:===" + paramMap);
		System.out.println("===== GETLIST Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();

		for (SearchHit hit : hits.getHits()) {
			Map contentMap = (Map) hit.getSource().get("CONTENT");
			ContentVo vo = new ContentVo();
			vo.setPrdContId(StringUtil.nullToLong(hit.getSource().get("PRD_CONT_ID")));
			vo.setIsDelete(StringUtil.nullToInteger(hit.getSource().get("IS_DELETE")));
			vo.setContentId(StringUtil.nullToLong(hit.getSource().get("CONTENT_ID")));
			vo.setName(StringUtil.nullToString(contentMap.get("NAME")));
			vo.setCduration(StringUtil.nullToLong(contentMap.get("CDURATION")));
			vo.setCpId(StringUtil.nullToLong(contentMap.get("COPYRIGHT_CPID")));
			vo.setKeyWords(StringUtil.nullToString(contentMap.get("KEY_WORDS")));
			vo.setFirstClassify(StringUtil.nullToLong(contentMap.get("DISPLAY_TYPE")));
			vo.setScopeAuthor(StringUtil.nullToInteger(contentMap.get("SCOPE")));
			vo.setCopyRightType(StringUtil.nullToInteger(contentMap.get("COPYRIGHT_TYPE")));
			vo.setFreeType(StringUtil.nullToInteger(contentMap.get("FEE_TYPE")));
			vo.setBcStatus(StringUtil.nullToInteger(hit.getSource().get("BC_STATUS")));
			vo.setDistStatus(StringUtil.nullToInteger(hit.getSource().get("DIST_STATUS")));
			vo.setPubStatus(StringUtil.nullToInteger(hit.getSource().get("PUB_STATUS")));
			vo.setCreateTime(StringUtil.nullToString(contentMap.get("CREATE_TIME")));
			vo.setId(StringUtil.nullToLong(contentMap.get("ID")));
			vo.setStatus(StringUtil.nullToString(contentMap.get("STATUS")));
			vo.setCategory(StringUtil.nullToString(contentMap.get("CATEGORY")));
			vo.setAssetId(StringUtil.nullToLong(contentMap.get("ASSET_ID")));
			vo.setBcrefuseReason(StringUtil.nullToString(hit.getSource().get("BC_REFUSE_REASON")));
			vo.setFormType(StringUtil.nullToString(contentMap.get("FORM_TYPE")));
			vo.setIsEmergency(StringUtil.nullToString(hit.getSource().get("IS_EMERGENCY")));
			vo.setGslbStatus(StringUtil.nullToString(contentMap.get("GSLB_STATUS")));
			vo.setCdnStatus(StringUtil.nullToString(contentMap.get("CDN_STATUS")));
			vo.setType(StringUtil.nullToString(contentMap.get("TYPE")));
			vo.setPublishNoVOMSStatus(StringUtil.nullToString(hit.getSource().get("PUBLISH_NO_VOMS_STATUS")));
			vo.setMovieLibId(StringUtil.nullToString(contentMap.get("MOVIE_LIB_ID")));
			vo.setPrdInfoId(StringUtil.nullToLong(hit.getSource().get("PRD_INFO_ID")));
			//vo.setSalConfigPrice(StringUtil.nullToString(hit.getSource().get("PRICE")));
			vo.setSalConfigPrice("0");
			vo.setSalPromPrice(StringUtil.nullToString(hit.getSource().get("SAL_PRICE")));
			vo.setDetail(StringUtil.nullToString(contentMap.get("DETAIL")));
			vo.setCacheCdnStatus(StringUtil.nullToString(contentMap.get("CACHE_CDN_STATUS")));
			vo.setUpdateFields(StringUtil.null2Str(contentMap.get("UPDATE_FIELDS")).replaceAll("，", ","));
			vo.setBcPriority(StringUtil.null2Str(contentMap.get("BC_PRIORITY")));
			vo.setCopy(StringUtil.null2Str(contentMap.get("COPY")));
			vo.setEndDate(StringUtil.null2Str(contentMap.get("END_DATE")));
			vo.setAccessPlatFormType(StringUtil.null2Str(contentMap.get("ACCESS_PLATFORM_TYPE")));
			vo.setIsDelete(StringUtil.nullToInteger(contentMap.get("IS_DELETE")));
			vo.setSerialSequence(StringUtil.null2Str(contentMap.get("SERIAL_SEQUENCE")));
			vo.setIsMultilingual(StringUtil.null2Str(contentMap.get("IS_MULTILIN_GUAL")));
			Object object = hit.getSource().get("ONTRIAL");
			if (object == null) {
				vo.setOnTrial(1);
			} else {
				vo.setOnTrial(StringUtil.nullToInteger(object));
			}
			vo.setMpid(StringUtil.null2Str(contentMap.get("MP_ID")));


			contentVoList.add(vo);
		}
		return contentVoList;
	}

	@Override
	public List<ContentVo> getProvinceContentList(Map<String, Object> paramMap, int start, int limit, Long id) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		TransportClient client = ESUtils.getTransportClient();
		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);

		BoolQueryBuilder qb = QueryBuilders.boolQuery();

		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("PRD_INFO_ID"))) {
			if (((String) paramMap.get("PRD_INFO_ID")).indexOf(",") <= 0) {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("PRD_INFO_ID"))));
			} else {
				String[] pids = ((String) paramMap.get("packageId")).split(",");
				BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
				for (int i = 0; i < pids.length; i++) {
					prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", pids[i]));
				}
				qb.filter(prdInfoBQB);
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("cpId"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_CPID", StringUtil.nullToString(paramMap.get("cpId"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("charge"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FEE_TYPE", StringUtil.nullToString(paramMap.get("charge"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("keywords"))) {
			qb.must(QueryBuilders.multiMatchQuery(StringUtil.nullToString(paramMap.get("keywords"))
					, "CONTENT.KEY_WORDS", "CONTENT.PRIMARY_KEY_WORD", "CONTENT.DETAIL", "CONTENT.LABELS", "CONTENT.NAME"));
		}
		if (!StringUtil.isNullStr(paramMap.get("bcType"))) {//待播控
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));

			if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
			}
		} else {

			if (!StringUtil.isNullStr(paramMap.get("viewType")) && paramMap.get("viewType").toString().equals("4")) {
				if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
					qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
				} else {
					qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("BC_STATUS", 1)).should(QueryBuilders.termQuery("BC_STATUS", 2)));
				}
			} else if (!StringUtil.isNullStr(paramMap.get("bcStatus"))) {
				qb.filter(QueryBuilders.termQuery("BC_STATUS", StringUtil.nullToInteger(paramMap.get("bcStatus"))));
			}
		}
		if (StringUtil.isNullStr(paramMap.get("contentId")) && StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			if (!StringUtil.isNullStr(paramMap.get("startTime")) && !StringUtil.isNullStr(paramMap.get("endTime"))) {
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format((String) paramMap.get("startTime"))).includeLower(true)
						.to(sdf.format((String) paramMap.get("endTime"))).includeUpper(true));
			} else {
				Calendar cal = Calendar.getInstance();
				cal.add(Calendar.DAY_OF_MONTH, -2);
				Date startDate = cal.getTime();
				cal.add(Calendar.DAY_OF_MONTH, +3);
				Date endDate = cal.getTime();
				qb.filter(QueryBuilders.rangeQuery("CONTENT.LAST_UPDATE_TIME")
						.from(sdf.format(startDate)).includeLower(true)
						.to(sdf.format(endDate)).includeUpper(true));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("disStatus"))) {
			qb.filter(QueryBuilders.termQuery("DIST_STATUS", StringUtil.nullToInteger(paramMap.get("disStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("pubStatus"))) {
			qb.filter(QueryBuilders.termQuery("PUB_STATUS", StringUtil.nullToInteger(paramMap.get("pubStatus"))));
		}


		//内容类型：爱情|喜剧；内容形态：预告
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			String sc = StringUtil.null2Str(paramMap.get("secondClassify")).replaceAll("：", ":").replaceAll("；", ";");
			if (sc.indexOf(":") > -1) {
				String[] sca = sc.split(";");
				if (sca != null && sca.length > 0) {
					for (String scc : sca) {
						String[] scca = scc.split(":");
						if (scca != null && scca.length == 2) {
							String key = scca[0];
							String value = scca[1];

							if (value.indexOf("|") > -1) {
								String[] vala = value.split("\\|");
								if (vala != null && vala.length > 0) {

									BoolQueryBuilder temp_bqb = QueryBuilders.boolQuery();
									for (int ii = 0; ii < vala.length; ii++) {
										temp_bqb.should(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(vala[ii]) + "*"));
									}

									qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
											QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key)).filter(temp_bqb)));
								}
							} else {
								qb.must(QueryBuilders.nestedQuery("CONTENT.SC",
										QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", key))
												.must(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(value) + "*"))));
							}
						}
					}
				}
			}
		}

		//节目ID
		if (!StringUtil.isNullStr(paramMap.get("firstLabel"))) {
			qb.filter(QueryBuilders.termQuery("PRD_CONT_ID", StringUtil.nullToLong(paramMap.get("firstLabel").toString().trim())));
		}
		//新发布状态
		if (!StringUtil.isNullStr(paramMap.get("vomsPublish"))) {
			if (paramMap.get("vomsPublish").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", StringUtil.nullToLong(paramMap.get("vomsPublish").toString().trim())));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("shieldDelCont")) && paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 0))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 1))
					.should(QueryBuilders.termQuery("CONTENT.STATUS", 3)));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			qb.filter(QueryBuilders.queryStringQuery(StringUtil.nullToString(paramMap.get("contentName"))).analyzer("ik_smart").field("CONTENT.NAME"));
//			qb.must(QueryBuilders.termQuery("CONTENT.NAME", StringUtil.nullToString(paramMap.get("contentName"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentId"))) {
			qb.filter(QueryBuilders.boolQuery()
					.should(QueryBuilders.termQuery("CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId"))))
					.should(QueryBuilders.termQuery("CONTENT.SERIAL_CONTENT_ID", StringUtil.nullToString(paramMap.get("contentId")))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", StringUtil.nullToString(paramMap.get("recommendation"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("status"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("status"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("copyRightType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.COPYRIGHT_TYPE", StringUtil.nullToString(paramMap.get("copyRightType"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("scopeOfAuthor"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.SCOPE", StringUtil.nullToString(paramMap.get("scopeOfAuthor"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cdnStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CDN_STATUS", StringUtil.nullToString(paramMap.get("cdnStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("gslbStatus"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", StringUtil.nullToString(paramMap.get("gslbStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("cacheCdnStatus"))) {
			if (paramMap.get("cacheCdnStatus").equals("-1")) {
				qb.filter(QueryBuilders.termQuery("CONTENT.GSLB_STATUS", "null"));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT.CACHE_CDN_STATUS", StringUtil.nullToString(paramMap.get("cacheCdnStatus"))));
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("albumStatus"))) {
			qb.mustNot(QueryBuilders.termQuery("CONTENT.STATUS", StringUtil.nullToString(paramMap.get("albumStatus"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("formType"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.FORM_TYPE", StringUtil.nullToString(paramMap.get("formType"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("optimal"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("optimal")))) {
				qb.filter(QueryBuilders.termQuery("CONTENT.OPTIMAL", StringUtil.nullToString(paramMap.get("optimal"))));
			} else {
				qb.filter(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("CONTENT.OPTIMAL", "1")).should(QueryBuilders.termQuery("CONTENT.OPTIMAL", "null")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("prdContXT"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容形态"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("prdContXT"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("releaseTime"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "播出年代"))
							.filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_VALUE", StringUtil.null2Str(paramMap.get("releaseTime"))))));
		}
		if (!StringUtil.isNullStr(paramMap.get("area"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "国家及地区"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("area")) + "*"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contCatergry"))) {
			qb.filter(QueryBuilders.nestedQuery("CONTENT.SC",
					QueryBuilders.boolQuery().filter(QueryBuilders.termQuery("CONTENT.SC.CLASSIFY_KEY", "内容类型"))
							.filter(QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + StringUtil.null2Str(paramMap.get("contCatergry")) + "*"))));
		}

		if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("orderFlag"))) {
			if ("0".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//包月
				qb.mustNot(QueryBuilders.termQuery("PRD_INFO.MONTH_TYPE", "null")).filter(QueryBuilders.termQuery("PRODUCT_ID", "null"));
			} else if ("1".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//按次
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.NUMBER_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "1")));
			} else if ("7".equals(StringUtil.null2Str(paramMap.get("orderFlag")))) {//免费
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery("PRD_INFO.FREE_TYPE", "null")))
						.should(QueryBuilders.termQuery("ORDER_FLAG", "7")));
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("channelPackageId"))) {

			if (!StringUtil.isNullStr(paramMap.get("saleCategory"))) {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.filter(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			} else {
				qb.filter(QueryBuilders.termQuery("CONTENT_FEE.SALE_CATEGORY", StringUtil.nullToInteger(paramMap.get("saleCategory"))))
						.should(QueryBuilders.termQuery("CONTENT_FEE.CHANNEL_PACKAGE_ID", StringUtil.nullToLong(paramMap.get("channelPackageId"))));
			}
		}


		/**
		 * 分省查询排序
		 */
		if (!StringUtil.isNullStr(paramMap.get("sort")) && paramMap.get("sort") != null && !"LAST_MODIFY_TIME".equals(paramMap.get("sort"))) {
			if (!StringUtil.isNullStr(paramMap.get("sortOrder")) && paramMap.get("sortOrder") != null) {//prdcontId,contentId,createTime排序
				if ("desc".equals(StringUtil.null2Str(paramMap.get("sortOrder")))) {
					builder.addSort(paramMap.get("sort") + "", SortOrder.DESC);
				} else {
					builder.addSort(paramMap.get("sort") + "", SortOrder.ASC);
				}
			} else {
				builder.addSort(paramMap.get("sort") + "", SortOrder.DESC);
			}
			if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {//1-显示子集， 其他-不显示子集
				qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
			}
		} else if ("LAST_MODIFY_TIME".equals(paramMap.get("sort"))) {//LAST_MODIFY_TIME 排序
			if (!StringUtil.isNullStr(paramMap.get("sortOrder")) && paramMap.get("sortOrder") != null) {
				if ("desc".equals(StringUtil.null2Str(paramMap.get("sortOrder")))) {
					builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_UPDATE_TIME").order(SortOrder.DESC));
				} else {
					builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_UPDATE_TIME").order(SortOrder.ASC));
				}
			} else {
				builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_UPDATE_TIME").order(SortOrder.DESC));
			}
			if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {//1-显示子集， 其他-不显示子集
				qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
			}
		} else {
			if (paramMap.get("bcType") != null && !StringUtil.isNullStr(paramMap.get("bcType"))) {
				builder.addSort(SortBuilders.fieldSort("CONTENT.STATUS").order(SortOrder.DESC));
				builder.addSort(SortBuilders.fieldSort("PUBLISH_NO_VOMS_TIME").order(SortOrder.DESC));
				//builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_MODIFY_TIME").order(SortOrder.DESC));
			} else {
				if (!"1".equals(StringUtil.nullToString(paramMap.get("displaySubSet")))) {//1-显示子集， 其他-不显示子集
					qb.mustNot(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7));
					builder.addSort(SortBuilders.fieldSort("PUBLISH_NO_VOMS_TIME").order(SortOrder.DESC));
					//builder.addSort(SortBuilders.fieldSort("CONTENT.LAST_MODIFY_TIME").order(SortOrder.DESC));
				}
			}
		}
		List<ContentVo> contentVoList = new ArrayList<ContentVo>();

		builder.setQuery(qb).setFrom(start).setSize(limit);
		System.out.println("=====GETLIST paramMap:===" + paramMap);
		//System.out.println("===== GETLIST Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();

		for (SearchHit hit : hits.getHits()) {
			Map contentMap = (Map) hit.getSource().get("CONTENT");
			ContentVo vo = new ContentVo();
			vo.setPrdContId(StringUtil.nullToLong(hit.getSource().get("PRD_CONT_ID")));
			vo.setContentId(StringUtil.nullToLong(hit.getSource().get("CONTENT_ID")));
			vo.setName(StringUtil.nullToString(contentMap.get("NAME")));
			vo.setCduration(StringUtil.nullToLong(contentMap.get("CDURATION")));
			vo.setCpId(StringUtil.nullToLong(contentMap.get("COPYRIGHT_CPID")));
			vo.setKeyWords(StringUtil.nullToString(contentMap.get("KEY_WORDS")));
			vo.setFirstClassify(StringUtil.nullToLong(contentMap.get("DISPLAY_TYPE")));
			vo.setScopeAuthor(StringUtil.nullToInteger(contentMap.get("SCOPE")));
			vo.setCopyRightType(StringUtil.nullToInteger(contentMap.get("COPYRIGHT_TYPE")));
			vo.setFreeType(StringUtil.nullToInteger(contentMap.get("FEE_TYPE")));
			vo.setBcStatus(StringUtil.nullToInteger(hit.getSource().get("BC_STATUS")));
			vo.setDistStatus(StringUtil.nullToInteger(hit.getSource().get("DIST_STATUS")));
			vo.setPubStatus(StringUtil.nullToInteger(hit.getSource().get("PUB_STATUS")));
			vo.setCreateTime(StringUtil.nullToString(hit.getSource().get("CREATE_TIME")));
			vo.setId(StringUtil.nullToLong(contentMap.get("ID")));
			vo.setStatus(StringUtil.nullToString(contentMap.get("STATUS")));
			vo.setCategory(StringUtil.nullToString(contentMap.get("CATEGORY")));
			vo.setAssetId(StringUtil.nullToLong(contentMap.get("ASSET_ID")));
			vo.setBcrefuseReason(StringUtil.nullToString(hit.getSource().get("BC_REFUSE_REASON")));
			vo.setFormType(StringUtil.nullToString(contentMap.get("FORM_TYPE")));
			vo.setIsEmergency(StringUtil.nullToString(hit.getSource().get("IS_EMERGENCY")));
			vo.setGslbStatus(StringUtil.nullToString(contentMap.get("GSLB_STATUS")));
			vo.setCdnStatus(StringUtil.nullToString(contentMap.get("CDN_STATUS")));
			vo.setType(StringUtil.nullToString(contentMap.get("TYPE")));
			vo.setPublishNoVOMSStatus(StringUtil.nullToString(hit.getSource().get("PUBLISH_NO_VOMS_STATUS")));
			vo.setMovieLibId(StringUtil.nullToString(contentMap.get("MOVIE_LIB_ID")));
			vo.setPrdInfoId(StringUtil.nullToLong(hit.getSource().get("PRD_INFO_ID")));
			//vo.setSalConfigPrice(StringUtil.nullToString(hit.getSource().get("PRICE")));
			vo.setSalConfigPrice("0");
			vo.setSalPromPrice(StringUtil.nullToString(hit.getSource().get("SAL_PRICE")));
			vo.setDetail(StringUtil.nullToString(contentMap.get("DETAIL")));
			vo.setCacheCdnStatus(StringUtil.nullToString(contentMap.get("CACHE_CDN_STATUS")));
			vo.setUpdateFields(StringUtil.null2Str(contentMap.get("UPDATE_FIELDS")).replaceAll("，", ","));
			vo.setBcPriority(StringUtil.null2Str(contentMap.get("BC_PRIORITY")));
			//新加的两个
			vo.setLastModifyTime(StringUtil.null2Str(contentMap.get("LAST_MODIFY_TIME")));
			vo.setPublishVOMSTime(StringUtil.nullToDate(StringUtil.null2Str(hit.getSource().get("PUBLISH_NO_VOMS_TIME")).replace("T", " "), "yyyy-MM-dd HH:mm:ss"));


			contentVoList.add(vo);
		}
		return contentVoList;
	}

	@Override
	public void updatePubStatus(String prdContId, String status) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to update the PubStatus of PrdCont:" + prdContId);
			UpdateRequest uRequest = new UpdateRequest();
			uRequest.index(ESUtils.index_name);
			uRequest.type("PRDCONTVO");
			uRequest.id(prdContId + "");
			uRequest.doc(XContentFactory.jsonBuilder()
					.startObject().field("PUB_STATUS", status)
					.startObject().field("PUB_TIME", ESUtils.timezoneSdf.format(new Date()))
					.startObject().field("UPDATE_TIME", ESUtils.timezoneSdf.format(new Date()))
					.endObject());
			client.update(uRequest.refresh(true)).get();
		} catch (Exception e) {
			log.info("====Exception!Failed to update the PubStatus of PrdCont:" + prdContId);
		}
	}

	@Override
	public void updateDistStatus(String contentId, String status) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateDistStatus :" + contentId);
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contentId));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("DIST_STATUS", status)
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateDistStatus:" + contentId);
		}
	}

	@Override
	public void updateCategoryList(String contentId, long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateCategoryList :" + prdInfoId);
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contentId))
					.must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("IS_DELETE", 2)
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateCategoryList:" + prdInfoId);
		}
	}

	@Override
	public void updatePublishBySerialCont(String serialContId, Long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updatePublishBySerialCont :" + prdInfoId);
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", serialContId))
					.must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId))
					.must(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", 14));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PUBLISH_NO_VOMS_STATUS", 10)
								.field("IS_EMERGENCY", 1)
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			//e.printStackTrace();
			log.info("====Exception!Failed to updatePublishBySerialCont:" + prdInfoId);
		}
	}

	@Override
	public void updatePrdInfo(String contentId, Long prdInfoIdOld, Long prdInfoIdNew) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updatePrdInfo :" + prdInfoIdOld);
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoIdOld))
					.must(QueryBuilders.termQuery("CONTENT_ID", contentId));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PRD_INFO_ID", prdInfoIdNew)
								.field("PUB_STATUS", 10)
								.field("PUBLISH_NO_VOMS_STATUS", 10)
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			//e.printStackTrace();
			log.info("====Exception!Failed to updatePrdInfo:" + prdInfoIdOld);
		}
	}

	@Override
	public void updateVomsPubStatus(Long prdContId, int status) {
		if (!this.exists(prdContId)) {
			log.info("====Firstly ES need to add new PrdCont:" + prdContId);
			PrdCont pc = prdContDao.findByPrdContId(prdContId);
			this.save(pc);
		} else {
			ESUtils.updateVomsPubStatus(prdContId, status);
		}
	}

	@Override
	public void republishLive(String contId, boolean bOnline, boolean isChannel) {
		int pubStatus = bOnline ? 10 : 20;
		int status = bOnline ? 0 : 2;
		TransportClient client = ESUtils.getTransportClient();
		SearchResponse actionGet = null;
		QueryBuilder qb = null;
		try {
			log.info("====ES Begin to republishLive :" + contId);
			if (isChannel && bOnline) {
				qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contId));
				actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
				if (actionGet != null) {
					SearchHits hits = actionGet.getHits();
					if (hits != null && hits.getHits() != null) {
						Map<String, Object> hitMap = null;
						BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
						for (SearchHit hit : hits.getHits()) {
							hitMap = hit.getSource();
							UpdateRequest uRequest = new UpdateRequest();
							uRequest.index(ESUtils.index_name);
							uRequest.type("PRDCONTVO");
							uRequest.id((String) hitMap.get("PRD_CONT_ID"));
							uRequest.doc(XContentFactory.jsonBuilder().startObject()
									.field("PUBLISH_NO_VOMS_STATUS", pubStatus)
									.endObject());
							bulkRequestBuilder.add(uRequest);
						}
						bulkRequestBuilder.setRefresh(true).execute().actionGet();
					}
				}

				qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contId));
				actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
				if (actionGet != null) {
					SearchHits hits = actionGet.getHits();
					if (hits != null && hits.getHits() != null) {
						Map<String, Object> hitMap = null;
						BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
						for (SearchHit hit : hits.getHits()) {
							hitMap = hit.getSource();
							UpdateRequest uRequest = new UpdateRequest();
							uRequest.index(ESUtils.index_name);
							uRequest.type("PRDCONTVO");
							uRequest.id((String) hitMap.get("PRD_CONT_ID"));
							uRequest.doc(XContentFactory.jsonBuilder().startObject()
									.field("PUBLISH_NO_VOMS_STATUS", pubStatus)
									.endObject());
							bulkRequestBuilder.add(uRequest);
						}
						bulkRequestBuilder.setRefresh(true).execute().actionGet();
					}
				}
			} else {
				qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contId)).must(QueryBuilders.termQuery("PUBLISH_NO_VOMS_STATUS", 12));
				actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
				if (actionGet != null) {
					SearchHits hits = actionGet.getHits();
					if (hits != null && hits.getHits() != null) {
						Map<String, Object> hitMap = null;
						BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
						for (SearchHit hit : hits.getHits()) {
							hitMap = hit.getSource();
							UpdateRequest uRequest = new UpdateRequest();
							uRequest.index(ESUtils.index_name);
							uRequest.type("PRDCONTVO");
							uRequest.id((String) hitMap.get("PRD_CONT_ID"));
							uRequest.doc(XContentFactory.jsonBuilder().startObject()
									.field("PUBLISH_NO_VOMS_STATUS", pubStatus)
									.endObject());
							bulkRequestBuilder.add(uRequest);
						}
						bulkRequestBuilder.setRefresh(true).execute().actionGet();
					}
				}

				qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contId)).must(QueryBuilders.termQuery("PUB_STATUS", 12));
				actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
				if (actionGet != null) {
					SearchHits hits = actionGet.getHits();
					if (hits != null && hits.getHits() != null) {
						Map<String, Object> hitMap = null;
						BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
						for (SearchHit hit : hits.getHits()) {
							hitMap = hit.getSource();
							UpdateRequest uRequest = new UpdateRequest();
							uRequest.index(ESUtils.index_name);
							uRequest.type("PRDCONTVO");
							uRequest.id((String) hitMap.get("PRD_CONT_ID"));
							uRequest.doc(XContentFactory.jsonBuilder().startObject()
									.field("PUB_STATUS", pubStatus)
									.endObject());
							bulkRequestBuilder.add(uRequest);
						}
						bulkRequestBuilder.setRefresh(true).execute().actionGet();
					}
				}
			}

			qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CONTENT_ID", contId));
			actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("FILE_ACTION", status)
								.endObject());
						bulkRequestBuilder.add(uRequest);
					}
					bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}


		} catch (Exception e) {
			//e.printStackTrace();
			log.info("====Exception!Failed to republishLive:" + contId);
		}
	}

	@Override
	public void updateAndDelSerials(String contIds, Long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateAndDelSerials:" + contIds);
			BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId));
			if (!StringUtil.isNullStr(contIds)) {
				if (contIds.indexOf(",") <= 0) {
					qb.filter(QueryBuilders.termQuery("SERIAL_CONTENT_ID", contIds));
				} else {
					String[] sids = contIds.split(",");
					BoolQueryBuilder scQB = QueryBuilders.boolQuery();
					for (int i = 0; i < sids.length; i++) {
						scQB.should(QueryBuilders.termQuery("SERIAL_CONTENT_ID", sids[i]));
					}
					qb.filter(scQB);
				}
			}

			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PUBLISH_NO_VOMS_STATUS", 20)
								.field("IS_DELETE", 4)
								.field("PUB_TIME", ESUtils.timezoneSdf.format(new Date()))
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateAndDelSerials:" + contIds);
		}
	}

	@Override
	public void updateAndDelLiveSerials(String contIds, Long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateAndDelLiveSerials:" + contIds);
			BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId));
			if (!StringUtil.isNullStr(contIds)) {
				if (contIds.indexOf(",") <= 0) {
					qb.filter(QueryBuilders.termQuery("LIVE_CONTENT_ID", contIds));
				} else {
					String[] sids = contIds.split(",");
					BoolQueryBuilder scQB = QueryBuilders.boolQuery();
					for (int i = 0; i < sids.length; i++) {
						scQB.should(QueryBuilders.termQuery("LIVE_CONTENT_ID", sids[i]));
					}
					qb.filter(scQB);
				}
			}

			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PUBLISH_NO_VOMS_STATUS", 20)
								.field("IS_DELETE", 5)
								.field("PUB_TIME", ESUtils.timezoneSdf.format(new Date()))
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateAndDelLiveSerials:" + contIds);
		}
	}

	@Override
	public void updateAndDelSerialsByInLimitRule(String contIds, Long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateAndDelSerialsByInLimitRule:" + contIds);
			BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId));
			if (!StringUtil.isNullStr(contIds)) {
				if (contIds.indexOf(",") <= 0) {
					qb.filter(QueryBuilders.termQuery("SERIAL_CONTENT_ID", contIds));
				} else {
					String[] sids = contIds.split(",");
					BoolQueryBuilder scQB = QueryBuilders.boolQuery();
					for (int i = 0; i < sids.length; i++) {
						scQB.should(QueryBuilders.termQuery("SERIAL_CONTENT_ID", sids[i]));
					}
					qb.filter(scQB);
				}
			}

			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PUBLISH_NO_VOMS_STATUS", 20)
								.field("IS_DELETE", 5)
								.field("PUB_TIME", ESUtils.timezoneSdf.format(new Date()))
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateAndDelSerialsByInLimitRule:" + contIds);
		}
	}

	@Override
	public void updateAndDelLiveSerialsByInLimitRule(String contIds, Long prdInfoId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updateAndDelLiveSerialsByInLimitRule:" + contIds);
			BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("PRD_INFO_ID", prdInfoId));
			if (!StringUtil.isNullStr(contIds)) {
				if (contIds.indexOf(",") <= 0) {
					qb.filter(QueryBuilders.termQuery("LIVE_CONTENT_ID", contIds));
				} else {
					String[] sids = contIds.split(",");
					BoolQueryBuilder scQB = QueryBuilders.boolQuery();
					for (int i = 0; i < sids.length; i++) {
						scQB.should(QueryBuilders.termQuery("LIVE_CONTENT_ID", sids[i]));
					}
					qb.filter(scQB);
				}
			}

			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("PUBLISH_NO_VOMS_STATUS", 20)
								.field("IS_DELETE", 5)
								.field("PUB_TIME", ESUtils.timezoneSdf.format(new Date()))
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updateAndDelLiveSerialsByInLimitRule:" + contIds);
		}
	}

	@Override
	public void updateCisStatusToThree(String prdContId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to update the VomsPubStatus of PrdCont:" + prdContId);
			UpdateRequest uRequest = new UpdateRequest();
			uRequest.index(ESUtils.index_name);
			uRequest.type("PRDCONTVO");
			uRequest.id(prdContId + "");
			uRequest.doc(XContentFactory.jsonBuilder().startObject()
					.field("CIS_STATUS", 3)
					.endObject());
			client.update(uRequest.refresh(true)).get();
		} catch (Exception e) {
			log.info("====Exception!Failed to updateCisStatusToThree:" + prdContId);
		}
	}

	@Override
	public void updatePrdContByAddOrUpdateCis() {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to updatePrdContByAddOrUpdateCis");
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("CIS_STATUS", 5));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null) {
				SearchHits hits = actionGet.getHits();
				if (hits != null && hits.getHits() != null) {
					Map<String, Object> hitMap = null;
					BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
					for (SearchHit hit : hits.getHits()) {
						hitMap = hit.getSource();
						UpdateRequest uRequest = new UpdateRequest();
						uRequest.index(ESUtils.index_name);
						uRequest.type("PRDCONTVO");
						uRequest.id((String) hitMap.get("PRD_CONT_ID"));
						uRequest.doc(XContentFactory.jsonBuilder().startObject()
								.field("CIS_STATUS", 3)
								.endObject());
						client.update(uRequest.refresh(true)).get();
						//bulkRequestBuilder.add(uRequest);
					}
					//bulkRequestBuilder.setRefresh(true).execute().actionGet();
				}
			}
		} catch (Exception e) {
			log.info("====Exception!Failed to updatePrdContByAddOrUpdateCis");
		}
	}

	@Override
	public void updateJmSearchStatus(Long prdContId, int status) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			log.info("====ES Begin to update the JmSearchStatus of PrdCont:" + prdContId);
			UpdateRequest uRequest = new UpdateRequest();
			uRequest.index(ESUtils.index_name);
			uRequest.type("PRDCONTVO");
			uRequest.id(prdContId + "");
			uRequest.doc(XContentFactory.jsonBuilder().startObject()
					.field("SEARCH_STATUS", status)
					.endObject());
			client.update(uRequest.refresh(true)).get();
		} catch (Exception e) {
			log.info("====Exception!Failed to update the JmSearchStatus of PrdCont:" + prdContId);
		}
	}

	@Override
	public void updatePrdInfoByPrdContId(Long prdContId, Long prdInfoIdNew) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			if (!this.exists(prdContId)) {
				log.info("====Firstly ES need to add new PrdCont:" + prdContId);
				PrdCont pc = prdContDao.findByPrdContId(prdContId);
				this.save(pc);
			}
			log.info("====ES Begin to update the updatePrdInfoByPrdContId of PrdCont:" + prdContId);
			UpdateRequest uRequest = new UpdateRequest();
			uRequest.index(ESUtils.index_name);
			uRequest.type("PRDCONTVO");
			uRequest.id(prdContId + "");
			uRequest.doc(XContentFactory.jsonBuilder().startObject()
					.field("PUBLISH_NO_VOMS_STATUS", 10)
					.field("PUB_STATUS", 10)
					.field("PRD_INFO_ID", prdInfoIdNew)
					.endObject());
			client.update(uRequest.refresh(true)).get();
		} catch (Exception e) {
			//e.printStackTrace();
			log.info("====Exception!Failed to update the updatePrdInfoByPrdContId of PrdCont:" + prdContId);
		}
	}

	@Override
	public long getPVContentCountByMap(Map<String, Object> paramMap) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		TransportClient client = ESUtils.getTransportClient();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);
		BoolQueryBuilder qb = QueryBuilders.boolQuery();

		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("packageId"))) {
			if (((String) paramMap.get("packageId")).indexOf(",") <= 0) {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("packageId"))));
			} else {
				String[] pids = ((String) paramMap.get("packageId")).split(",");
				BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
				for (int i = 0; i < pids.length; i++) {
					prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", pids[i]));
				}
				qb.filter(prdInfoBQB);
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("category"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CATEGORY", StringUtil.nullToString(paramMap.get("category"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentLevel"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CONTENT_LEVEL", StringUtil.nullToString(paramMap.get("contentLevel"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			qb.filter(QueryBuilders.queryStringQuery(StringUtil.nullToString(paramMap.get("contentName"))).analyzer("ik_smart").field("CONTENT.NAME"));
			//qb.must(QueryBuilders.termQuery("CONTENT.NAME", StringUtil.nullToString(paramMap.get("contentName"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", paramMap.get("recommendation")));
		}
		if (!StringUtil.isNullStr(paramMap.get("teleplaySearchType"))) {
			if ("1".equals(StringUtil.null2Str(paramMap.get("teleplaySearchType")))) {
				qb.must(QueryBuilders.termQuery("CONTENT.FORM_TYPE", "7")); //1-只显示子集
			}
			if ("2".equals(StringUtil.null2Str(paramMap.get("teleplaySearchType")))) {
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 6))
						.should(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7))); //2-剧集壳、子集都显示
			} else {
				qb.must(QueryBuilders.termQuery("CONTENT.FORM_TYPE", "6"));    //默认只显示剧集壳
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + paramMap.get("secondClassify") + "*");
		}

		if (!StringUtil.isNullStr(paramMap.get("createTimeStart")) || !StringUtil.isNullStr(paramMap.get("createTimeEnd"))) {
			qb.filter(QueryBuilders.rangeQuery("CONTENT.NEW_CREATE_TIME").from(paramMap.get("createTimeStart")).includeLower(true).
					to(paramMap.get("createTimeEnd")).includeLower(true));
		}

		builder.setQuery(qb);
		log.info("=====paramMap:===" + paramMap);
		log.info("===== Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();
		log.info("===== hits.getTotalHits():===" + hits.getTotalHits());
		return hits.getTotalHits();
	}

	@Override
	public List<ContentVo> getPVContentList(Map<String, Object> paramMap, int start, int limit) {
		String index_name = StringUtil.null2Str(systemConfigDao.findByCkey("Index_PrdContDao"));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		TransportClient client = ESUtils.getTransportClient();
		SearchRequestBuilder builder = client.prepareSearch(index_name).setTypes("PRDCONTVO").setSearchType(SearchType.DEFAULT);

		BoolQueryBuilder qb = QueryBuilders.boolQuery();
		if (StringUtil.isNullStr(paramMap.get("shieldDelCont")) || paramMap.get("shieldDelCont").equals("1")) {
			qb.filter(QueryBuilders.termQuery("IS_DELETE", 0));
		}

		if (!StringUtil.isNullStr(paramMap.get("packageId"))) {
			if (((String) paramMap.get("packageId")).indexOf(",") <= 0) {
				qb.filter(QueryBuilders.termQuery("PRD_INFO_ID", StringUtil.nullToString(paramMap.get("packageId"))));
			} else {
				String[] pids = ((String) paramMap.get("packageId")).split(",");
				BoolQueryBuilder prdInfoBQB = QueryBuilders.boolQuery();
				for (int i = 0; i < pids.length; i++) {
					prdInfoBQB.should(QueryBuilders.termQuery("PRD_INFO_ID", pids[i]));
				}
				qb.filter(prdInfoBQB);
			}
		}

		if (!StringUtil.isNullStr(paramMap.get("firstClassify"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.DISPLAY_TYPE", StringUtil.nullToString(paramMap.get("firstClassify"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("category"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CATEGORY", StringUtil.nullToString(paramMap.get("category"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentLevel"))) {
			qb.filter(QueryBuilders.termQuery("CONTENT.CONTENT_LEVEL", StringUtil.nullToString(paramMap.get("contentLevel"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("contentName"))) {
			qb.filter(QueryBuilders.queryStringQuery(StringUtil.nullToString(paramMap.get("contentName"))).analyzer("ik_smart").field("CONTENT.NAME"));
			//qb.must(QueryBuilders.termQuery("CONTENT.NAME", StringUtil.nullToString(paramMap.get("contentName"))));
		}
		if (!StringUtil.isNullStr(paramMap.get("recommendation"))) {
			qb.must(QueryBuilders.termQuery("CONTENT.RECOMMENDATION", paramMap.get("recommendation")));
		}
		if (!StringUtil.isNullStr(paramMap.get("teleplaySearchType"))) {
			if ("1".equals(StringUtil.null2Str(paramMap.get("teleplaySearchType")))) {
				qb.must(QueryBuilders.termQuery("CONTENT.FORM_TYPE", "7")); //1-只显示子集
			}
			if ("2".equals(StringUtil.null2Str(paramMap.get("teleplaySearchType")))) {
				qb.filter(QueryBuilders.boolQuery()
						.should(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 6))
						.should(QueryBuilders.termQuery("CONTENT.FORM_TYPE", 7))); //2-剧集壳、子集都显示
			} else {
				qb.must(QueryBuilders.termQuery("CONTENT.FORM_TYPE", "6"));    //默认只显示剧集壳
			}
		}
		if (!StringUtil.isNullStr(paramMap.get("secondClassify"))) {
			QueryBuilders.wildcardQuery("CONTENT.SC.CLASSIFY_VALUE", "*" + paramMap.get("secondClassify") + "*");
		}

		if (!StringUtil.isNullStr(paramMap.get("createTimeStart")) || !StringUtil.isNullStr(paramMap.get("createTimeEnd"))) {
			qb.filter(QueryBuilders.rangeQuery("CONTENT.NEW_CREATE_TIME").from(paramMap.get("createTimeStart")).includeLower(true).
					to(paramMap.get("createTimeEnd")).includeLower(true));
		}

		builder.setQuery(qb).setFrom(start).setSize(limit);
		log.info("=====GETLIST paramMap:===" + paramMap);
		log.info("===== GETLIST Query build:===" + builder.toString());
		SearchResponse response = builder.execute().actionGet();
		SearchHits hits = response.getHits();

		List<ContentVo> contentVoList = new ArrayList<ContentVo>();
		for (SearchHit hit : hits.getHits()) {
			Map contentMap = (Map) hit.getSource().get("CONTENT");
			ContentVo vo = new ContentVo();
			vo.setPrdContId(StringUtil.nullToLong(hit.getSource().get("PRD_CONT_ID")));
			vo.setName(StringUtil.nullToString(contentMap.get("NAME")));
			vo.setDetail(StringUtil.nullToString(contentMap.get("DETAIL")));
			vo.setPrdInfoId(StringUtil.nullToLong(hit.getSource().get("PRD_INFO_ID")));
			vo.setKeyWords(StringUtil.nullToString(contentMap.get("PRIMARY_KEY_WORD")));
			vo.setRecommendation(StringUtil.nullToString(contentMap.get("RECOMMENDATION")));
			vo.setCreateTime(StringUtil.nullToString(contentMap.get("CREATE_TIME")));
			vo.setCategory(StringUtil.nullToString(contentMap.get("CATEGORY")));
			vo.setContentLevel(StringUtil.nullToString(contentMap.get("CONTENT_LEVEL")));
			vo.setFirstClassify(StringUtil.nullToLong(contentMap.get("DISPLAY_TYPE")));
			vo.setFirstLabel(StringUtil.nullToString(contentMap.get("DISPLAY_NAME")));
			vo.setContentId(StringUtil.nullToLong(hit.getSource().get("CONTENT_ID")));
			contentVoList.add(vo);
		}
		return contentVoList;
	}


	@Override
	public boolean exists(Long prdContId) {
		TransportClient client = ESUtils.getTransportClient();
		try {
			QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("_id", prdContId));
			SearchResponse actionGet = client.prepareSearch(ESUtils.index_name).setTypes("PRDCONTVO").setQuery(qb).execute().actionGet();
			if (actionGet != null && actionGet.getHits().getHits().length > 0) {
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			//e.printStackTrace();
			log.info("=====exists Exception, false ==========");
			return false;
		}
	}

	@Override
	public PrdCont save(PrdCont prdCont) {
		if (this.exists(prdCont.getPrdContId())) {
			log.info("=====PrdContES begin to update existing PrdCont:" + prdCont.getPrdContId());
			ESUtils.updatePrdCont(prdCont);
		} else {
			log.info("=====PrdContES begin to add new PrdCont:" + prdCont.getPrdContId());
			ESUtils.addPrdCont(prdCont, null);
		}
		return prdCont;
	}

	public void remove(Long prdContId) {
		log.info("=====PrdContES begin to delete PrdCont:" + prdContId);
		ESUtils.deletePrdCont(prdContId);
	}
}
